#include "randomthread.h"
#include <vector>
RandomThread::RandomThread(QThread *parent) : QThread(parent)
{

}

void RandomThread::run()
{
    std::vector<int> nums;
    for(int i = 0; i < 50000; i++)
    {
        nums.push_back(rand()% 100000);
    }
    emit Generate(nums);//手动发出信号
}

SortThread::SortThread(QThread *parent)
{

}

void SortThread::run()
{
    for(int i = 0; i < nums.size() - 1; i++)
    {
        for(int j = 0; j < nums.size() - i - 1; j++)
        {
            if(nums[j] > nums[j+1])
            {
                std::swap(nums[j], nums[j+1]);
            }
        }
    }
    emit SortFinished(nums);//发出排序结束的信号
}
